package corejava2;

import java.util.Iterator;
import java.util.LinkedList;

public class TestLinkedList {
    public static void main(String[] args) {
        LinkedList<Integer> a = new LinkedList<>();
        for (int i = 0; i < 10; i++) {
            a.add(i);
        }
        System.out.println(a);
        System.out.println(a.get(3));//O(n)
        Iterator<Integer> it = a.iterator();
        System.out.println(it.next());//0
        System.out.println(it.hasNext());//true
        System.out.println(it.next());//1


        for (int i = 0; i < 100; i++) {
            if (!it.hasNext()) {
                it = a.iterator();
            }


            System.out.print(" " + it.next());

        }
    }
}
